from flask_restful import Resource
from restful.pack.post import PK_OnePost, PK_OnePostWithComment
from restful.response import ResponseNotFound,  ResponseSuccess
from models import  QueryOneInstance,  Blog

# 单个帖子浏览

class CommonPostView(Resource):
    def get(self,pid):
        blog = QueryOneInstance(Blog,{'id':pid})

        if not blog:
            return ResponseNotFound("未找到博客")
        return ResponseSuccess(data=PK_OnePostWithComment(pid))

class CheckPostView(Resource):
    def get(self,pid):
        blog = QueryOneInstance(Blog,{'id':pid})

        if not blog:
            return ResponseNotFound("未找到博客")
        return ResponseSuccess(data=PK_OnePost(pid))

#多个帖子浏览